Ext.define('AmpleHarvest.objects.metadata.metadata',
		{
			extend			: 'Ext.panel.Panel',
			alias			: 'widget.ampleharvest-objects-metadata-metadata',
			layout			: 'fit',
			autoScroll		: true,
			cls				: 'html',
			border			: 0,
			bodyStyle		: 'padding:5px;',
			// MEMBER VARIABLES
			
			// PASSED MEMBER VARIABLES
			// REQUIRED
			m_str_data_source	: false,
			// OPTIONAL
			m_obj_params		: {},			

			listeners		:
			{
				dataResponse	: function(obj_response)
				{
					if(Ext.isObject(obj_response.data))
					{
						console.log('METADATA');
						console.log(obj_response);
						var metaData = [];
						this.itemCount = 0;
						for (var value in JsonObject)
						{

							this.store.add(AmpleHarvest.DATA.Model.cMetadata.create(
									{
										name	: JsonObject[value].name,
										value	: JsonObject[value].value
									}));
							this.itemCount++;
						}
					}
				},
				
				beforedestory	: function(obj_self)
				{
					obj_self.m_obj_util.destroy();
				}
			},
			
			initComponent	: function()
			{
				if(this.m_str_data_source)
				{
					this.m_obj_util = Ext.create('AmpleHarvest.util.utility');
					this.m_obj_util.AHcaller = this;

					this.m_obj_util.getData(this.m_str_data_source, this.m_obj_params, {},'GET', {}, {});
				} else {
					this.html = "This object requires a resource path as m_str_data_source";
				}
					
				this.callParent();
			},
			
			store			: Ext.create('Ext.data.Store',
					{
						model	: 'AmpleHarvest.DATA.Model.cMetadata',
						proxy	:
						{
							type	: 'memory'
						}

					}),
			columns			:
				[
						{
							header		: "Name",
							dataIndex	: "name",
							flex		: 1
						},
						{
							header		: "Value",
							dataIndex	: "value",
							flex		: 1
						},
						{
							xtype	: 'actioncolumn',
							width	: 25,
							items	:
							[
									{
										iconCls	: 'toolbar-article-navigation-pivot action-icon',
										tooltip	: 'Pivot',
										handler	: function(obj_Grid, int_RowIndex,
												int_ColIndex)
										{
											var obj_Rec = obj_Grid.getStore().getAt(int_RowIndex);
											var str_Prop = "string."+obj_Rec.get("name");
											var str_Value = obj_Rec.get("value");

											str_Prop = str_Prop.toLowerCase();
											str_Prop = str_Prop.replace(/ /gi,"_");
											
											if (!str_Value)
											{
												Ext.Msg.alert("Error",
														"You must enter some data to search for."
												);
												return;
											}
											
											var obj_Query = new Array();
											obj_Query.push(
													{
														property	: str_Prop,
														value		: str_Value,
														type		: "condition",
														condition	: '==',
														join		: 'AND'
													});
											m_obj_AmpleHarvest_ViewPort
													.fireEvent(
															AmpleHarvest.eventHandler.cWindowEvents.C_STR_EVENT_ADVANCED_QUERY,
															obj_Query
													);
										}
									}
							]
						}
				],
		});